<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <title>首页</title>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <!--<script th:src="@{/js/jquery.min.js}"/>-->
    <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
    <meta charset="utf-8">

    <style>
        html body {
            margin: 0;
            padding: 0;
            background-color: #e4e4e4;
        }


        .center {

            height: 89%;
        }

        tr {
            margin: 0;
        }

        td {
            border: 1px solid;
            text-align: center;
            width: 180px;
            height: 30px;
        }

        table {
            margin: 0 auto 0 auto;
            margin-top: 80px;
        }

        .table-th {
            background-color: #cccccc;
        }

        .button {
            position: absolute;
            left: 302px;
            top: 35px;
            width: 150px;
            height: 40px;
            border-radius: 5px;
        }

        .button:hover {
            width: 155px;
            height: 42px;
            background-color: #cccccc;
        }

        .on {
            background-color: #f3f3da;
            padding-bottom: 40px;
            position: absolute;
            text-align: center;
            border: 2px solid #727369;
            top: 40%;
            left: 50%;
            height: 400px;
            width: 400px;
            border-radius: 20px;
            transform: translate(-50%, -50%);
            z-index: 999;
        }

        .sub:hover {
            color: #7985b0;
            width: 110px;
            height: 47px;
        }


        .form-input:hover {
            width: 320px;
            height: 47px;
            border: 4px #64ff6e solid;
            color: #795ebe;
            font-size: 24px;
        }

        input::-webkit-input-placeholder {
            color: #ccc;
        }

        input::-ms-input-placeholder {
            color: #ccc;
        }

        .form-input {
            border: 2px solid #727369;
            width: 300px;
            height: 45px;
            border-radius: 5px;
            margin-top: 30px;
            text-align: center;

        }

        .sub {
            width: 100px;
            height: 45px;
            border: 0;
            border-radius: 5px;
            margin-top: 20px;
            text-align: center;
        }

    </style>

    <script type="text/javascript">

        function add() {
            $("#name").val("");
            $("#address").val("");
            $("#phone").val("");
            $("#id").val("0");
            $(".on").attr("hidden", false);
        }

        function closeWinDow() {
            $(".on").attr("hidden", true);
        }

        /*function updatdData(name, address, phone, id) {*/
        function updatdData(obj) {
            $("#name").val(obj.name);
            $("#address").val(obj.address);
            $("#phone").val(obj.phone);
            $("#id").val(obj.id);
            $(".on").attr("hidden", false);
        }

        function delData(id) {

            let b = confirm("确定要删除数据吗？");

            if (b) {
                window.location.href = "/sss/index/delData?id=" + id;
                return true;
            } else {
                return false;
            }

        }


    </script>

</head>
<body>

<div class="top"><input type="button" value="添加" onclick="add()" class="button"></div>
<div class="center">
    <table>
        <tr class="table-th">
            <td>编号</td>
            <td>姓名</td>
            <td>地址</td>
            <td>电话</td>
            <td>操作</td>
        </tr>


        <tr class="table-tr" th:each="resume:${resumes}">
            <td th:text="${resume.id}"></td>
            <td th:text="${resume.name}"></td>
            <td th:text="${resume.address}"></td>
            <td th:text="${resume.phone}"></td>
            <td>
                <a href="#" th:onclick="updatdData([[${resume}]])">修改</a>
                <a href="#" th:onclick="delData([[${resume.id}]])">删除</a>
            </td>
        </tr>

    </table>
</div>

<div class="on" hidden="hidden">
    <button onclick="closeWinDow()" style="background-color: #e4e4e4;position: fixed;right: 16px;top: 2px">关闭</button>
    <form id="myForm" th:action="@{/index/updata}" method="post">
        <input type="text" placeholder="name" id="name" name="name" class="form-input"><br>
        <input type="text" placeholder="address" id="address" name="address" class="form-input"><br>
        <input type="text" placeholder="phone" id="phone" name="phone" class="form-input"><br>
        <input type="hidden" id="id" name="id" value="0">
        <input type="submit" value="提交" class="sub">
    </form>

</div>

</body>

</html>
